class FollowupRecordApi < Grape::API
    format 'json'
  
    namespace :followuprecords do
      
      desc '添加跟进记录'
      params do
        requires :companies_id, type: Integer
        requires :followup_time, type: DateTime
        requires :followup_employee_code, type: String
        requires :contacts_id, type: Integer
        requires :contact_channel, type: Integer
        requires :followup_phase, type: String
        optional :followup_status, type: Integer, default: 0
        optional :note, type: String
        optional :creator_id, type: String
      end
      post 'add_followup_record' do
        content_type 'application/json'
        FollowupRecordService.add(params)
      end

      desc '批量更新跟进记录状态'
      params do
        requires :ids, type: Array[Integer]
      end
      post 'batch_update_followup_status' do
        content_type 'application/json'
        FollowupRecordService.batch_update_followup_status_by_ids(params[:ids])
      end

      desc '根据跟进id查询跟进记录详情'
      params do
        requires :id, type: Integer
      end
      get 'query_by_id' do
        content_type 'application/json'
        FollowupRecordService.query_follow_record_by_id(params[:id])
      end

      desc '更新跟进记录'
      params do
        requires :id, type: Integer
        requires :followup_time, type: DateTime
        requires :followup_employee_code, type: String
        requires :contacts_id, type: Integer
        requires :contact_channel, type: Integer
        requires :followup_phase, type: String
        optional :followup_status, type: Integer
        optional :note, type: String
      end
      post 'update' do
        content_type 'application/json'
        FollowupRecordService.update(params)
      end

      desc '删除跟进记录'
      params do
        requires :id, type: Integer
      end
      post 'delete' do
        content_type 'application/json'
        FollowupRecordService.delete_by_id(params[:id])
      end

      desc '根据公司id查询跟进记录'
      params do
        requires :companies_id, type: Integer
      end
      get 'query_followup_records_by_companies_id' do
        FollowupRecordService.query_by_companies_id(params[:companies_id])
      end

    end
end